//
// Created by 谢哲 on 2021/5/8.
//

#include <iostream>
#include <vector>
using namespace std;

vector<int> vdata(10, 0);
vector<vector<int>> ans;
void dfs(int pos, int remain) {
    if (remain <= 0) return;
    if (remain > (10-pos) * 3 || remain < (10-pos)) return;
    if (pos == 9) {
        if (remain > 3) return;
        vdata[9] = remain;
        ans.emplace_back(vdata);
        return;
    }
    for (int i=1; i<=3; ++i) {
        vdata[pos] = i;
        dfs(pos+1, remain-i);
    }
}

int main() {
    int n;
    cin >> n;

    dfs(0, n);
    cout << ans.size() << "\n";
    for (auto& p: ans) {
        for (auto& q: p) {
            cout << q << " ";
        }
        cout << "\n";
    }

    return 0;
}